package com.chen.java.enjoyedu.concurrent.ch5;

import java.util.concurrent.locks.LockSupport;

/**
 * @author: Chentian
 * @date: Created in 2021/7/2 6:52
 * @desc LockSupport.park() 响应中断
 */
public class LockSupportInterrupt {

    public static void main(String[] args) {

        Runnable task = () -> {
            System.out.println(Thread.currentThread().getName()+": 开始执行。。。");
            LockSupport.park();
            System.out.println(Thread.currentThread().getName()+": 是否中断："+Thread.currentThread().isInterrupted());
        };

        Thread thread = new Thread(task);
        thread.start();
        System.out.println(Thread.currentThread().getName()+": "+thread.getName()+" 已经启动，但内部进行了 park()。");
        thread.interrupt();
        System.out.println(Thread.currentThread().getName()+": 调用 interrupt()");

    }

}
